package games.mapacman.common;

import games.mapacman.client.GameScreen;
import games.mapacman.server.MaPacmanZone;
import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import marauroa.common.game.Definition.Type;

public class ScoreSign extends Sign {

	protected int x, y, score;
	// Scrolls 30 pixel with 2pixels per frame
	private final int SCROLL_HEIGHT = 30;
	private final int SCROLL_SPEED = 2;

	public ScoreSign(int score, int x, int y, MaPacmanZone zone) {
		disappear = -1;
		myObject = new RPObject();
		myObject.put("type", Constants.TYPE_SCORESIGN);
		myObject.put("x", x);
		myObject.put("y", y);
		myObject.put("score", score);
		myObject.put("delete", 6);
		myObject.put("zoneid", zone.getName());
		this.x = x;
		this.y = y;
		this.score = score;
		this.zone = zone;
	}

	public ScoreSign(RPObject object) {
		disappear = SCROLL_HEIGHT / SCROLL_SPEED;
		myObject = object;
		x = object.getInt("x");
		y = object.getInt("y");
		score = object.getInt("score");
	}

	public static void initRPClass() {
		RPClass sign = new RPClass(Constants.TYPE_SCORESIGN);
		sign.isA("position");
		sign.addAttribute("score", Type.INT);
		sign.addAttribute("delete", Type.INT);
	}

	public void draw(GameScreen screen) {
		screen.drawString("" + score, x, y, 5,
				0 - (SCROLL_HEIGHT - (disappear * SCROLL_SPEED)));
		disappear--;
	}

}
